package com.ccsoft.atools.controller;


import com.ccsoft.atools.model.SysUser;
import com.ccsoft.atools.service.SysUserService;
import com.ccsoft.atools.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/sysUser")
public class SysUserController {

    @Autowired
    private SysUserService service;

    @DeleteMapping("/deleteByPrimaryKey/{iid}")
    public JsonResult deleteByPrimaryKey(@PathVariable java.lang.Integer iid) {
        return JsonResult.ok(service.deleteByPrimaryKey(iid));
    }

    @GetMapping("/selectByPrimaryKey/{iid}")
    public JsonResult selectByPrimaryKey(@PathVariable java.lang.Integer iid) {
        return JsonResult.ok(service.selectByPrimaryKey(iid));
    }

    @GetMapping("/selectAll")
    public JsonResult selectAll() {
        return JsonResult.ok(service.selectAll());
    }


    @PostMapping("/insert")
    public JsonResult insert(@RequestBody SysUser record) {
        return JsonResult.ok(service.insertSelective(record));
    }

    @PutMapping("/update")
    public JsonResult update(@RequestBody SysUser record) {
        return JsonResult.ok(service.updateByPrimaryKey(record));
    }

    @GetMapping("/selectByUserId/{userid}")
    public JsonResult selectByUserId(@PathVariable String userid) {
        return JsonResult.ok(service.selectByUserId(userid));
    }

    @GetMapping("/getRoles/{userIid}/{userSid}")
    public JsonResult getRoles(@PathVariable Integer userIid,@PathVariable String userSid) {
        return JsonResult.ok(service.getRoles(userIid,userSid));
    }
}